﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ReverseWordsInASentece
{
   public static class StringExtension
    {

        public static string ReverseWordsInASentece(this string input)
        {
            if (input.Length < 0)
                return string.Empty;

            string result = string.Empty;
            string temp = string.Empty;

            for (int i = 0; i < input.Length; i++)
            {                
                if (input[i] != ' ')
                {
                    temp += input[i];
                }
                else
                {
                    result = temp + ' ' + result;
                    temp = string.Empty;
                }

            }

            return temp + ' ' + result;
        }       
    }
}
